﻿using System;
using System.Collections.Generic;
using UnityEngine;
using Object = UnityEngine.Object;

namespace ZyGame.Editor.Avatar
{
    [PathOptions("ProjectSettings/AvatarElementConfig.asset", PathOptions.Localtion.Project)]
    internal class AvatarElementConfig : Config<AvatarElementConfig>
    {
        public Object iconOutput;
        public List<NodeData> nodes;
        public List<TiletData> tilets;
        public List<ElementItemData> elements;
    }

    public class OutData
    {
        public int element;
        public bool is_normal;
        public string icon;
        public string texture;
        public string group;
        public string model;
        public uint version;
        public uint crc;
    }

    [Serializable]
    public class TiletData
    {
        public string name;
        public GameObject skelton;
    }

    [Serializable]
    public class NodeData
    {
        public Element element;
        public List<NodeChild> childs;
    }

    [Serializable]
    public class NodeChild
    {
        public Element element;
        public List<string> path;
    }

    [Serializable]
    public class ElementItemData
    {
        public string group;
        public bool isNormal;
        public string skeleton;
        public GameObject fbx;
        public Element element;
        public uint version;
        public Texture2D icon;


        [NonSerialized]
        public Mesh mesh;
        [NonSerialized]
        public Material material;

        public OutData GetOutData(string outpath)
        {
            return new OutData
            {
                element = (int)element,
                is_normal = isNormal,
            };
        }
    }

}
